﻿@model IEnumerable<FCNS.ERP.Models.ErpPxPlan>

@{
    ViewBag.Title = "学员名单";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>@ViewBag.Title</h2>
<script type="text/javascript">
    $(document).ready(function () {
        function GetData(id, searchText) {
            var text = "";
            $.get("/Px/PxOrderGet", {
                planId: id,
                searchText: searchText
            }, function (data) {
                    text += data;
            });
            return text;
        }

        var table = $('.dataTable').DataTable();
        $('.dataTable tbody').on('click', 'td.details-control', function () {
            var tr = $(this).closest('tr');
            var row = table.row(tr);
            if (row.child.isShown()) {
                row.child.hide();
                tr.removeClass('shown');
            }
            else {
                row.child(GetData($(this).attr("data-Id"),"")).show();
                tr.addClass('shown');
                for (j = 0; j < tr.children().length; j++) {
                    var w = $(".dataTable tr:eq(1) td:eq(" + j + ")").width();
                    $(".dataTableD tr:first td:eq(" + j + ")").width(w);
                }
            }
        }); 

        //取消默认事件，重新设置
        $('.dataTables_filter [type=search]').unbind();
        $('.dataTables_filter [type=search]').keypress(function (e) {
            if (e.keyCode == 13) {
                var result = GetData(-1, $('.dataTables_filter [type=search]').val());
                $(".dataTable tbody").html(result);
                $(".dataTable").DataTable();
                $('.dataTables_filter [type=search]').val("");
            }
        });

        $(".dataTable tbody").on('click', '.orderShenHe', function () {
            var r = true;
            $.get("/Px/IsKqIdExist", {
                kqId: $(this).attr("data-kqId")
            }, function (data, status) {
                if (status == "success") {
                    if (data != "success") {
                        alert(data);
                      r= false;
                    }
                }
                else {
                    alert('远程服务器链接失败');
                    r= false;
                }
                });
            return r;
        });
    });
</script>
<p>
    <a class="newObjA" href="/Px/PxOrderNew">新增</a>
</p>    
<table class="dataTable">
    <thead>
        <tr>
            <th></th>
            <th>课程</th>
            <th>
                学员
            </th>
            <th>
             金额
            </th>

            <th>
           开单日期
            </th>
            <th>
               门禁编号
            </th> 
            <th>
             状态
            </th> 
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
        <tr>
            <td class="details-control" data-Id="@item.Id"></td>
            <td>
                @item.Name
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td> 
            <td></td>
        </tr>
        }
    </tbody>
</table>
